package com.hzqy.persistence.dao.hotel;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.hzqy.web.vo.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.hzqy.persistence.dao.core.PersistenceDao;

@Repository
public class WchatHotelDao extends PersistenceDao<PmsUserVo, Integer> {
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	
	public List<CmContentVo> selectContentListByCatalogId(int id,int f_po_id,int pageNo,int pageSize,String f_cp_cprid,CmContentVo contentVo){
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("f_catalog_id", id);
		map.put("f_cc_companyid", f_po_id);
		map.put("firstResult", pageNo);
		map.put("pageSize", pageSize);
		String[] f_cp_cpridArr = f_cp_cprid.split(",");
		map.put("f_cp_cpridArr", f_cp_cpridArr);
		map.put("f_cp_cprid", f_cp_cprid);
		map.put("f_cc_status", contentVo.getF_cc_status());
		map.put("f_cc_searchname", contentVo.getF_cc_searchname());
		map.put("f_cc_name", contentVo.getF_cc_name());
		map.put("f_cc_actors", contentVo.getF_cc_actors());
		return getSqlSession().selectList(this.getNamespace() + "selectContentListByCatalogId", map);
	}
	
	public List<CmContentVo> selectContentListByCatalogIdThree(int id,int pageNo,int pageSize,String f_cp_cprid,CmContentVo contentVo){
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("f_catalog_id", id);
		map.put("firstResult", pageNo);
		map.put("pageSize", pageSize);
		String[] f_cp_cpridArr = f_cp_cprid.split(",");
		map.put("f_cp_cpridArr", f_cp_cpridArr);
		map.put("f_cp_cprid", f_cp_cprid);
		map.put("f_cc_status", contentVo.getF_cc_status());
		map.put("f_cc_searchname", contentVo.getF_cc_searchname());
		map.put("f_cc_name", contentVo.getF_cc_name());
		map.put("f_cc_actors", contentVo.getF_cc_actors());
		return getSqlSession().selectList(this.getNamespace() + "selectContentListByCatalogIdThree", map);
	}
	
	public List<CmContentVo> selectContentListByCatalogIdNoTime(int id,int f_po_id,int pageNo,int pageSize,String f_cp_cprid,CmContentVo contentVo){
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("f_catalog_id", id);
		map.put("f_cc_companyid", f_po_id);
		map.put("firstResult", pageNo);
		map.put("pageSize", pageSize);
		String[] f_cp_cpridArr = f_cp_cprid.split(",");
		map.put("f_cp_cpridArr", f_cp_cpridArr);
		map.put("f_cp_cprid", f_cp_cprid);
		map.put("f_cc_status", contentVo.getF_cc_status());
		map.put("f_cc_searchname", contentVo.getF_cc_searchname());
		map.put("f_cc_name", contentVo.getF_cc_name());
		map.put("f_cc_actors", contentVo.getF_cc_actors());
		return getSqlSession().selectList(this.getNamespace() + "selectContentListByCatalogIdNoTime", map);
	}
	
	public int selectUserCountByName(String f_pu_name , String f_pu_phone,String f_pu_pwd){
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("f_pu_name", f_pu_name);
		map.put("f_pu_phone", f_pu_phone);
		map.put("f_pu_pwd", f_pu_pwd);
		return getSqlSession().selectOne(this.getNamespace() + "selectUserCountByName", map);
	}
	
	public int setOpenid(String f_pu_email,String f_up_name){
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("f_pu_email", f_pu_email);
		map.put("f_up_name", f_up_name);
		return getSqlSession().update(this.getNamespace() + "setOpenid", map);
	}
	
	public int updateOrgMmodel(int f_po_id,int f_po_model,String f_po_model_name){
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("f_po_id", f_po_id);
		map.put("f_po_model", f_po_model);
		map.put("f_po_model_name", f_po_model_name);
		return getSqlSession().update(this.getNamespace() + "updateOrgMmodel", map);
	}
	
	public int updateOrgUserCount(int f_po_id,int user_count){
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("f_po_id", f_po_id);
		map.put("f_po_obligate1", user_count);
		return getSqlSession().update(this.getNamespace() + "updateOrgUserCount", map);
	}
	
	public List<PmsOrgVo> selectPms_org(PmsOrgVo pms_org){
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("f_po_name", pms_org.getF_po_name());
		map.put("f_po_parentId", pms_org.getF_po_parentId());
		map.put("f_po_status", pms_org.getF_po_status());
		return getSqlSession().selectList(this.getNamespace() + "selectPms_org", map);
	}
	
	public int select_count_hotel(){
		Map<String,Object> map = new HashMap<String, Object>();
		return getSqlSession().selectOne(this.getNamespace() + "select_count_hotel", map);
	}
	
	public int selectOrg_Content(String f_po_name,String f_cc_name){
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("f_po_name", f_po_name);
		map.put("f_cc_name", f_cc_name);
		return getSqlSession().selectOne(this.getNamespace() + "selectOrg_Content", map);
	}
	
	public List<CmContentVo> selectContentByCompanyid(String f_catalog_id,String f_cco_orgId){
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("f_ccc_catalogid", f_catalog_id);
		map.put("f_cco_orgId", f_cco_orgId);
		return getSqlSession().selectList(this.getNamespace() + "selectContentByCompanyid", map);
	}
	
	public int insertPmsOrgUser(int f_pou_userId, int f_pou_orgId){
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("f_pou_userId", f_pou_userId);
		map.put("f_pou_orgId", f_pou_orgId);
		return getSqlSession().insert(this.getNamespace() + "insertPmsOrgUser", map);
	}
	
	public List<PmsUserVo> selectOpenid(String f_pu_email){
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("f_pu_email", f_pu_email);
		return getSqlSession().selectList(this.getNamespace() + "selectOpenid", map);
	}
	
	public List<PmsOrgVo> selectHotelListByManager(int f_pu_id, int f_po_id) {
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("f_pu_id", f_pu_id);
		map.put("f_po_id", f_po_id);
		return getSqlSession().selectList(this.getNamespace() + "selectHotelListByManager", map);
	}

	public List<PmsUserVo> selectHotelUserList(int f_po_id) {
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("f_po_id", f_po_id);
		return getSqlSession().selectList(this.getNamespace() + "selectHotelUserList", map);
	}

	public int deleteHotelUser(int f_pu_id) {
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("f_pu_id", f_pu_id);
		return getSqlSession().delete(this.getNamespace() + "deleteHotelUser", map);
	}
	
	public int selectContentCount(int f_cc_type) {
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("f_cc_type", f_cc_type);
		return getSqlSession().selectOne(this.getNamespace() + "selectContentCount", map);
	}
	
	public List<PmsOrgVo> selectOrgNameById(String f_pu_id){
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("f_pou_userId", f_pu_id);
		return getSqlSession().selectList(this.getNamespace() + "selectOrgNameById", map);
	}

	public int insertUser(PmsUserVo pmsUserVo) {
		return getSqlSession().insert(this.getNamespace() + "insertUser", pmsUserVo);
	}
	
	public int updateUser(PmsUserVo pmsUserVo) {
		return getSqlSession().update(this.getNamespace() + "updateUser", pmsUserVo);
	}

	public int updateContent(CmContentVo cmContentVo) {
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("f_cc_id", cmContentVo.getF_cc_id());
		map.put("f_cc_desc", cmContentVo.getF_cc_desc());
		map.put("f_cc_onlinedate", cmContentVo.getF_cc_onlinedate());
		map.put("f_cc_offlinedate", cmContentVo.getF_cc_offlinedate());
		map.put("f_cc_obligate1", cmContentVo.getF_cc_obligate1());
		map.put("f_cc_obligate2", cmContentVo.getF_cc_obligate2());
		map.put("f_cc_status", cmContentVo.getF_cc_status());
		map.put("f_cc_name", cmContentVo.getF_cc_name());
		return getSqlSession().update(this.getNamespace() + "updateContent", map);
	}

	public CmContentVo selectPic(int id) {
		return getSqlSession().selectOne(this.getNamespace() + "selectPic", id);
	}



	public int insertBind(CmCatalogContentVo cmCatalogContentVo) {
		return getSqlSession().insert(this.getNamespace() + "insertBind", cmCatalogContentVo);
	}
	
	public int user_handover(int lostuserid, int getuserid) {
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("lostuserid", lostuserid);
		map.put("getuserid", getuserid);
		return getSqlSession().update(this.getNamespace() + "user_handover", map);
	}
	
	public List<StatDataTotalTopRankingVo> selectTopRanking(StatDataTotalTopRankingVo statDataTotalTopRankingVo) {
		return getSqlSession().selectList(this.getNamespace() + "selectTopRanking",statDataTotalTopRankingVo);
	}

	public List<StatDataTotalTopRankingVo> selectTopRankingOrgRoomData(StatDataTotalTopRankingVo statDataTotalTopRankingVo) {
		return getSqlSession().selectList(this.getNamespace() + "selectTopRankingOrgRoomData",statDataTotalTopRankingVo);
	}

	public List<StatDataTotalTopRankingVo> selectTopRankingOrgRoomDataMonth(StatDataTotalTopRankingVo statDataTotalTopRankingVo) {
		return getSqlSession().selectList(this.getNamespace() + "selectTopRankingOrgRoomDataMonth",statDataTotalTopRankingVo);
	}

	public PmsUserVo selectUser(int f_pu_id) {
		return getSqlSession().selectOne(this.getNamespace() + "selectUser",f_pu_id);
	}
	
	public String selectBICPOrgByServerid(String serverid) {
		return getSqlSession().selectOne(this.getNamespace() + "selectBICPOrgByServerid",serverid);
	}
	
	public PmsOrgVo selectOrgById(int f_po_id) {
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("f_po_id", f_po_id);
		return getSqlSession().selectOne(this.getNamespace() + "selectOrgById",map);
	}
	
	public List<CmContentVo> selectContent(CmContentVo cmContentVo) {
		String namespace = this.getNamespace();
		return getSqlSession().selectList(namespace + "selectContent", cmContentVo);
	}

	
	public int insertHotelUserNeedsVo(HotelUserNeedsVo vo) {
		return getSqlSession().insert(this.getNamespace()+"insertHotelUserNeedsVo",vo);
	}

	public List<HotelUserNeedsVo> selectHotelUserNeedsList(Map<String,Object> map){
		String namespace = this.getNamespace();
		return getSqlSession().selectList(namespace + "selectHotelUserNeedsList", map);
	}
	
	public List<PmsOrgVo> selectOrgByContentId(int f_cc_id) {
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("f_cc_id", f_cc_id);
		return getSqlSession().selectList(this.getNamespace() + "selectOrgByContentId",map);
	}
	public Map<String,Object> selectDivideUserBillSumOrg(Map<String,Object> map) {
		return getSqlSession().selectOne(this.getNamespace() + "selectDivideUserBillSumOrg",map);
	}
    public List<StatDataOndemandVo> selectStatDataOndemandVo(Map<String,Object> map) {
        return  getSqlSession().selectList(this.getNamespace() + "selectStatDataOndemandVo",map);
    }

    public int selectUserBillCount(UserBillVo userBillVo) {
        String namespace = this.getNamespace();
        return getSqlSession().selectOne(namespace + "selectUserBillListCount", userBillVo);
    }

    public List<UserBillVo> selectUserBillList(Map<String,Object> map){
        String namespace = this.getNamespace();
        return getSqlSession().selectList(namespace + "selectUserBillList", map);
    }

    public int selectExcelCount(UserBillVo userBillVo) {
        String namespace = this.getNamespace();
        return getSqlSession().selectOne(namespace + "selectExcelContentCount", userBillVo);
    }

    public List<UserBillVo> selectExcelList(Map<String,Object> map){
        String namespace = this.getNamespace();
        return getSqlSession().selectList(namespace + "selectExcelList", map);
    }

	public PmsUserVo findUserOrg(PmsUserVo puv) {
		return findOne("findUserOrg", puv);
	}
	public PmsUserVo findUserOrgByName(PmsUserVo puv) {
		String namespace = this.getNamespace();
		return getSqlSession().selectOne(namespace + "findUserOrgByName", puv);
	}


	public int deleteContent(int f_cc_id) {
		String namespace = this.getNamespace();
		return getSqlSession().update(namespace + "deleteContent", f_cc_id);
	}

	public int insertContent(CmContentVo contentVo) {
		return getSqlSession().insert(this.getNamespace() + "insertContent", contentVo);
	}

	public int insertContentOrg(int f_cc_id,String f_cco_orgId) {
		String namespace = this.getNamespace();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("f_cc_id", f_cc_id);
		map.put("f_cco_orgId", f_cco_orgId);
		return getSqlSession().insert(namespace + "insertContentOrg", map);
	}

	public int loginOut(PmsUserVo userVo) {
		return getSqlSession().update(this.getNamespace() + "loginOut", userVo);
	}
}
